<?php
namespace common\models;


class TeamTotalLog extends BaseModel
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'team_total_log';
    }


    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['member_id', 'money'], 'required'],
            [['member_id', 'mch_id', 'source_id', 'from_member_id', 'level', 'create_time'], 'integer'],
            [['money'], 'number'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'member_id' => 'Member ID',
            'mch_id' => 'Mch ID',
            'money' => '金额',
            'source_id' => '来源ID',
            'from_member_id' => '来源会员',
            'level' => '层级',
            'create_time' => '创建时间',
        ];
    }    

	/*
		* 数据列表
		* whereArr 条件
		* params 基本参数 包含 field order page limit
		* extends  扩展信息 一些相关的信息
		* 
	*/	
	public static function dataList($whereArr, $params, $extends = array())
	{
		$model  = self::find();
		$where  = isset($whereArr['where']) ? $whereArr['where'] : [];
		$whereAnd = isset($whereArr['and'])?$whereArr['and']:[];
		$models = self::queryFormart($model,$where,$params,$whereAnd);
		$model  = $models['model'];
		
		$data  = $model->asarray()->all();
		if(!$data) return array();

		//扩展信息
		if(!$extends) return $data;

		foreach($extends as $extend)
		{

		}

		return $data;	
	}

	public static function getOne($where, $field = ['*'])
	{
		return self::find()->select($field)->where($where)->asarray()->one();
	}


	public static function getAll($where = [], $field = ['*'])
	{
		return self::find()->select($field)->where($where)->asarray()->all();
	}

}